//
//  NewsCell.m
//  ZeroCorner
//
//  Created by lanou3g on 15/11/19.
//  Copyright © 2015年 Zero_Zhou. All rights reserved.
//

#import "NewsCell.h"
#import "UIImageView+WebCache.h"

@interface NewsCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imageIcon;
@property (weak, nonatomic) IBOutlet UILabel *lblTitle;
@property (weak, nonatomic) IBOutlet UILabel *lblSubtitle;
@property (weak, nonatomic) IBOutlet UIImageView *imgOther1;
@property (weak, nonatomic) IBOutlet UIImageView *imgOther2;

@end
@implementation NewsCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)setNewsModel:(ZZNewsModel *)NewsModel{
    if (_NewsModel != NewsModel) {
        _NewsModel = nil;
        _NewsModel = NewsModel;
        [self layoutModel];
    }
}
- (void)layoutModel{
    [self.imageIcon sd_setImageWithURL:[NSURL URLWithString:self.NewsModel.imgsrc] placeholderImage:[UIImage imageNamed:@""]];
    self.lblTitle.text = self.NewsModel.title;
    self.lblSubtitle.text = self.NewsModel.digest;
    
    //多图
    if (self.NewsModel.imgextra.count == 2) {
        [self.imgOther1 sd_setImageWithURL:[NSURL URLWithString:self.NewsModel.imgextra[0][@"imgsrc"]]placeholderImage:[UIImage imageNamed:@"302"]];
        [self.imgOther2 sd_setImageWithURL:[NSURL URLWithString:self.NewsModel.imgextra[1][@"imgsrc"]]placeholderImage:[UIImage imageNamed:@"302"]];
    }
}

+(NSString *)idForRow:(ZZNewsModel *)NewsModel{
    if (NewsModel.hasHead && NewsModel.photosetID) {
        return @"TopImageCell";
    }else if (NewsModel.hasHead){
        return @"TopTextCell";
    }else if (NewsModel.imgType){
        return @"BigImageCell";
    }else if (NewsModel.imgextra){
        return @"ImagesCell";
    }else{
        return @"NewsCell";
    }
}
+ (CGFloat)heightForRow:(ZZNewsModel *)NewsModel{
    if (NewsModel.hasHead && NewsModel.photosetID) {
        return 245;
    }else if (NewsModel.hasHead){
        return 245;
    }else if(NewsModel.imgType ){
        return 170;
    }else if(NewsModel.imgextra){
        return 130;
    }else{
        return 80;
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
